From 9c2712214a1ddc02fb37b605dfdd8a5dd7a4db8b Mon Sep 17 00:00:00 2001 From: Ramez Medhat Date: Sat, 28 Mar 2026 17:14:15 +0200 Subject: [PATCH] screenshot: Snap cursor to the center of the handle on press When dragging the screenshot area handle from the outer sides, it is currently impossible to move them to the edges or corners of the screen, as the cursor is constrained to the monitor. Fix this by snapping the cursor to the center of the handle when starting the resize operation. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/9113 Part-of: --- js/ui/screenshot.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index e0ec8b76a..499baa8f4 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -481,6 +481,44 @@ const UIAreaSelector = GObject.registerClass({ const rightX = leftX + width - 1; const bottomY = topY + height - 1; + let snapX = this._dragStartX; + let snapY = this._dragStartY; + + switch (cursor) { + case Clutter.CursorType.NW_RESIZE: + snapX = leftX; + snapY = topY; + break; + case Clutter.CursorType.NE_RESIZE: + snapX = rightX; + snapY = topY; + break; + case Clutter.CursorType.SW_RESIZE: + snapX = leftX; + snapY = bottomY; + break; + case Clutter.CursorType.SE_RESIZE: + snapX = rightX; + snapY = bottomY; + break; + case Clutter.CursorType.N_RESIZE: + snapY = topY; + break; + case Clutter.CursorType.S_RESIZE: + snapY = bottomY; + break; + case Clutter.CursorType.W_RESIZE: + snapX = leftX; + break; + case Clutter.CursorType.E_RESIZE: + snapX = rightX; + break; + } + + const backend = this.get_context().get_backend(); + backend.get_default_seat().warp_pointer(snapX, snapY); + [this._dragStartX, this._dragStartY] = [snapX, snapY]; + // For moving, start X and Y are the top left corner, while // last X and Y are the bottom right corner. if (cursor === Clutter.CursorType.MOVE) { -- 2.39.5